// ignore_for_file: non_constant_identifier_names
// ignore_for_file: camel_case_types
// ignore_for_file: prefer_single_quotes

import 'package:star_author/model/backflow_list_item_entity.dart';
import 'package:star_author/model/compensate_entity.dart';
import 'package:star_author/model/notifications_newest_info_entity.dart';
import 'package:star_author/model/push_msg_info_entity.dart';
import 'package:star_author/model/shop_title_entity.dart';
import 'package:star_author/model/user_info_entity.dart';
import 'package:star_author/model/wallet_automatic_list_item_entity.dart';
import 'package:star_author/model/wallet_particular_list_item_entity.dart';
import 'package:star_author/views/stream/model/live_good_list_entity.dart';
import 'package:star_author/widgets/dialog/notice_dialog/model/notice_entity.dart';
// This file is automatically generated. DO NOT EDIT, all your changes would be lost.
import 'package:flutter/material.dart' show debugPrint;

JsonConvert jsonConvert = JsonConvert();
typedef JsonConvertFunction<T> = T Function(Map<String, dynamic> json);

class JsonConvert {
  static final Map<String, JsonConvertFunction> _convertFuncMap = {
    (BackflowListItemEntity).toString(): BackflowListItemEntity.fromJson,
    (BackflowListItemGoods).toString(): BackflowListItemGoods.fromJson,
    (BackflowListItemGoodsCover).toString():
        BackflowListItemGoodsCover.fromJson,
    (CompensateEntity).toString(): CompensateEntity.fromJson,
    (CompensateData).toString(): CompensateData.fromJson,
    (NotificationsNewestInfoEntity).toString():
        NotificationsNewestInfoEntity.fromJson,
    (NotificationsNewestInfoBackflow).toString():
        NotificationsNewestInfoBackflow.fromJson,
    (NotificationsNewestInfoBackflowExtra).toString():
        NotificationsNewestInfoBackflowExtra.fromJson,
    (NotificationsNewestInfoWithdraw).toString():
        NotificationsNewestInfoWithdraw.fromJson,
    (NotificationsNewestInfoWithdrawExtra).toString():
        NotificationsNewestInfoWithdrawExtra.fromJson,
    (NotificationsNewestInfoEvaluation).toString():
        NotificationsNewestInfoEvaluation.fromJson,
    (NotificationsNewestInfoEvaluationExtra).toString():
        NotificationsNewestInfoEvaluationExtra.fromJson,
    (NotificationsNewestInfoOrder).toString():
        NotificationsNewestInfoOrder.fromJson,
    (NotificationsNewestInfoOrderExtra).toString():
        NotificationsNewestInfoOrderExtra.fromJson,
    (NotificationsNewestInfoStarBackflow).toString():
        NotificationsNewestInfoStarBackflow.fromJson,
    (NotificationsNewestInfoStarBackflowExtra).toString():
        NotificationsNewestInfoStarBackflowExtra.fromJson,
    (NotificationsNewestInfoTender).toString():
        NotificationsNewestInfoTender.fromJson,
    (NotificationsNewestInfoTenderExtra).toString():
        NotificationsNewestInfoTenderExtra.fromJson,
    (PushMsgInfoEntity).toString(): PushMsgInfoEntity.fromJson,
    (ShopTitleEntity).toString(): ShopTitleEntity.fromJson,
    (ShopTitleData).toString(): ShopTitleData.fromJson,
    (ShopChlildrenEntity).toString(): ShopChlildrenEntity.fromJson,
    (ShopTitleChildrenEntity).toString(): ShopTitleChildrenEntity.fromJson,
    (UserInfoEntity).toString(): UserInfoEntity.fromJson,
    (UserInfoSummary).toString(): UserInfoSummary.fromJson,
    (UserInfoMaintainStudios).toString(): UserInfoMaintainStudios.fromJson,
    (UserInfoApply).toString(): UserInfoApply.fromJson,
    (UserInfoIdentification).toString(): UserInfoIdentification.fromJson,
    (WalletAutomaticListItemEntity).toString():
        WalletAutomaticListItemEntity.fromJson,
    (WalletParticularListItemEntity).toString():
        WalletParticularListItemEntity.fromJson,
    (LiveGoodListEntity).toString(): LiveGoodListEntity.fromJson,
    (LiveGoodListData).toString(): LiveGoodListData.fromJson,
    (LiveGoodListDataGoods).toString(): LiveGoodListDataGoods.fromJson,
    (LiveGoodListDataGoodsCover).toString():
        LiveGoodListDataGoodsCover.fromJson,
    (LiveGoodListDataLogistic).toString(): LiveGoodListDataLogistic.fromJson,
    (LiveGoodListDataWinningOrder).toString():
        LiveGoodListDataWinningOrder.fromJson,
    (LiveGoodListMeta).toString(): LiveGoodListMeta.fromJson,
    (NoticeEntity).toString(): NoticeEntity.fromJson,
    (NoticeData).toString(): NoticeData.fromJson,
  };

  T? convert<T>(dynamic value) {
    if (value == null) {
      return null;
    }
    return asT<T>(value);
  }

  List<T?>? convertList<T>(List<dynamic>? value) {
    if (value == null) {
      return null;
    }
    try {
      return value.map((dynamic e) => asT<T>(e)).toList();
    } catch (e, stackTrace) {
      debugPrint('asT<$T> $e $stackTrace');
      return <T>[];
    }
  }

  List<T>? convertListNotNull<T>(dynamic value) {
    if (value == null) {
      return null;
    }
    try {
      return (value as List<dynamic>).map((dynamic e) => asT<T>(e)!).toList();
    } catch (e, stackTrace) {
      debugPrint('asT<$T> $e $stackTrace');
      return <T>[];
    }
  }

  T? asT<T extends Object?>(dynamic value) {
    if (value == null) {
      return null;
    }
    if (value is T) {
      return value;
    }
    final String type = T.toString();
    try {
      final String valueS = value.toString();
      if (type == "String") {
        return valueS as T;
      } else if (type == "int") {
        final int? intValue = int.tryParse(valueS);
        if (intValue == null) {
          return double.tryParse(valueS)?.toInt() as T?;
        } else {
          return intValue as T;
        }
      } else if (type == "double") {
        return double.parse(valueS) as T;
      } else if (type == "DateTime") {
        return DateTime.parse(valueS) as T;
      } else if (type == "bool") {
        if (valueS == '0' || valueS == '1') {
          return (valueS == '1') as T;
        }
        return (valueS == 'true') as T;
      } else if (type == "Map" || type.startsWith("Map<")) {
        return value as T;
      } else {
        if (_convertFuncMap.containsKey(type)) {
          return _convertFuncMap[type]!(value) as T;
        } else {
          throw UnimplementedError('$type unimplemented');
        }
      }
    } catch (e, stackTrace) {
      debugPrint('asT<$T> $e $stackTrace');
      return null;
    }
  }

  //list is returned by type
  static M? _getListChildType<M>(List<Map<String, dynamic>> data) {
    if (<BackflowListItemEntity>[] is M) {
      return data
          .map<BackflowListItemEntity>(
              (Map<String, dynamic> e) => BackflowListItemEntity.fromJson(e))
          .toList() as M;
    }
    if (<BackflowListItemGoods>[] is M) {
      return data
          .map<BackflowListItemGoods>(
              (Map<String, dynamic> e) => BackflowListItemGoods.fromJson(e))
          .toList() as M;
    }
    if (<BackflowListItemGoodsCover>[] is M) {
      return data
          .map<BackflowListItemGoodsCover>((Map<String, dynamic> e) =>
              BackflowListItemGoodsCover.fromJson(e))
          .toList() as M;
    }
    if (<CompensateEntity>[] is M) {
      return data
          .map<CompensateEntity>(
              (Map<String, dynamic> e) => CompensateEntity.fromJson(e))
          .toList() as M;
    }
    if (<CompensateData>[] is M) {
      return data
          .map<CompensateData>(
              (Map<String, dynamic> e) => CompensateData.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoEntity>[] is M) {
      return data
          .map<NotificationsNewestInfoEntity>((Map<String, dynamic> e) =>
              NotificationsNewestInfoEntity.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoBackflow>[] is M) {
      return data
          .map<NotificationsNewestInfoBackflow>((Map<String, dynamic> e) =>
              NotificationsNewestInfoBackflow.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoBackflowExtra>[] is M) {
      return data
          .map<NotificationsNewestInfoBackflowExtra>((Map<String, dynamic> e) =>
              NotificationsNewestInfoBackflowExtra.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoWithdraw>[] is M) {
      return data
          .map<NotificationsNewestInfoWithdraw>((Map<String, dynamic> e) =>
              NotificationsNewestInfoWithdraw.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoWithdrawExtra>[] is M) {
      return data
          .map<NotificationsNewestInfoWithdrawExtra>((Map<String, dynamic> e) =>
              NotificationsNewestInfoWithdrawExtra.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoEvaluation>[] is M) {
      return data
          .map<NotificationsNewestInfoEvaluation>((Map<String, dynamic> e) =>
              NotificationsNewestInfoEvaluation.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoEvaluationExtra>[] is M) {
      return data
          .map<NotificationsNewestInfoEvaluationExtra>(
              (Map<String, dynamic> e) =>
                  NotificationsNewestInfoEvaluationExtra.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoOrder>[] is M) {
      return data
          .map<NotificationsNewestInfoOrder>((Map<String, dynamic> e) =>
              NotificationsNewestInfoOrder.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoOrderExtra>[] is M) {
      return data
          .map<NotificationsNewestInfoOrderExtra>((Map<String, dynamic> e) =>
              NotificationsNewestInfoOrderExtra.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoStarBackflow>[] is M) {
      return data
          .map<NotificationsNewestInfoStarBackflow>((Map<String, dynamic> e) =>
              NotificationsNewestInfoStarBackflow.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoStarBackflowExtra>[] is M) {
      return data
          .map<NotificationsNewestInfoStarBackflowExtra>(
              (Map<String, dynamic> e) =>
                  NotificationsNewestInfoStarBackflowExtra.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoTender>[] is M) {
      return data
          .map<NotificationsNewestInfoTender>((Map<String, dynamic> e) =>
              NotificationsNewestInfoTender.fromJson(e))
          .toList() as M;
    }
    if (<NotificationsNewestInfoTenderExtra>[] is M) {
      return data
          .map<NotificationsNewestInfoTenderExtra>((Map<String, dynamic> e) =>
              NotificationsNewestInfoTenderExtra.fromJson(e))
          .toList() as M;
    }
    if (<PushMsgInfoEntity>[] is M) {
      return data
          .map<PushMsgInfoEntity>(
              (Map<String, dynamic> e) => PushMsgInfoEntity.fromJson(e))
          .toList() as M;
    }
    if (<ShopTitleEntity>[] is M) {
      return data
          .map<ShopTitleEntity>(
              (Map<String, dynamic> e) => ShopTitleEntity.fromJson(e))
          .toList() as M;
    }
    if (<ShopTitleData>[] is M) {
      return data
          .map<ShopTitleData>(
              (Map<String, dynamic> e) => ShopTitleData.fromJson(e))
          .toList() as M;
    }
    if (<ShopChlildrenEntity>[] is M) {
      return data
          .map<ShopChlildrenEntity>(
              (Map<String, dynamic> e) => ShopChlildrenEntity.fromJson(e))
          .toList() as M;
    }
    if (<ShopTitleChildrenEntity>[] is M) {
      return data
          .map<ShopTitleChildrenEntity>(
              (Map<String, dynamic> e) => ShopTitleChildrenEntity.fromJson(e))
          .toList() as M;
    }
    if (<UserInfoEntity>[] is M) {
      return data
          .map<UserInfoEntity>(
              (Map<String, dynamic> e) => UserInfoEntity.fromJson(e))
          .toList() as M;
    }
    if (<UserInfoSummary>[] is M) {
      return data
          .map<UserInfoSummary>(
              (Map<String, dynamic> e) => UserInfoSummary.fromJson(e))
          .toList() as M;
    }
    if (<UserInfoMaintainStudios>[] is M) {
      return data
          .map<UserInfoMaintainStudios>(
              (Map<String, dynamic> e) => UserInfoMaintainStudios.fromJson(e))
          .toList() as M;
    }
    if (<UserInfoApply>[] is M) {
      return data
          .map<UserInfoApply>(
              (Map<String, dynamic> e) => UserInfoApply.fromJson(e))
          .toList() as M;
    }
    if (<UserInfoIdentification>[] is M) {
      return data
          .map<UserInfoIdentification>(
              (Map<String, dynamic> e) => UserInfoIdentification.fromJson(e))
          .toList() as M;
    }
    if (<WalletAutomaticListItemEntity>[] is M) {
      return data
          .map<WalletAutomaticListItemEntity>((Map<String, dynamic> e) =>
              WalletAutomaticListItemEntity.fromJson(e))
          .toList() as M;
    }
    if (<WalletParticularListItemEntity>[] is M) {
      return data
          .map<WalletParticularListItemEntity>((Map<String, dynamic> e) =>
              WalletParticularListItemEntity.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListEntity>[] is M) {
      return data
          .map<LiveGoodListEntity>(
              (Map<String, dynamic> e) => LiveGoodListEntity.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListData>[] is M) {
      return data
          .map<LiveGoodListData>(
              (Map<String, dynamic> e) => LiveGoodListData.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListDataGoods>[] is M) {
      return data
          .map<LiveGoodListDataGoods>(
              (Map<String, dynamic> e) => LiveGoodListDataGoods.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListDataGoodsCover>[] is M) {
      return data
          .map<LiveGoodListDataGoodsCover>((Map<String, dynamic> e) =>
              LiveGoodListDataGoodsCover.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListDataLogistic>[] is M) {
      return data
          .map<LiveGoodListDataLogistic>(
              (Map<String, dynamic> e) => LiveGoodListDataLogistic.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListDataWinningOrder>[] is M) {
      return data
          .map<LiveGoodListDataWinningOrder>((Map<String, dynamic> e) =>
              LiveGoodListDataWinningOrder.fromJson(e))
          .toList() as M;
    }
    if (<LiveGoodListMeta>[] is M) {
      return data
          .map<LiveGoodListMeta>(
              (Map<String, dynamic> e) => LiveGoodListMeta.fromJson(e))
          .toList() as M;
    }
    if (<NoticeEntity>[] is M) {
      return data
          .map<NoticeEntity>(
              (Map<String, dynamic> e) => NoticeEntity.fromJson(e))
          .toList() as M;
    }
    if (<NoticeData>[] is M) {
      return data
          .map<NoticeData>((Map<String, dynamic> e) => NoticeData.fromJson(e))
          .toList() as M;
    }

    debugPrint("${M.toString()} not found");

    return null;
  }

  static M? fromJsonAsT<M>(dynamic json) {
    if (json is List) {
      return _getListChildType<M>(
          json.map((e) => e as Map<String, dynamic>).toList());
    } else {
      return jsonConvert.asT<M>(json);
    }
  }
}
